package com.gwkj.zxjl_user.Utils;

import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

/**
 * 键盘的显示和隐藏
 * Created by fujh on 16/1/8.
 */
public class KeyBoardUtils {

    //隐藏虚拟键盘
    public static void HideKeyboard(View v)
    {
        InputMethodManager imm = (InputMethodManager)v.getContext( ).getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isActive()){
            imm.hideSoftInputFromWindow(v.getApplicationWindowToken( ), 0);
        }
    }

    //显示虚拟键盘
    public static void ShowKeyboard(final View v)
    {
        InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(v, InputMethodManager.SHOW_FORCED);
    }

    //输入法是否显示着
    public static boolean isOpenKeyBoard(View v) {
        InputMethodManager imm = (InputMethodManager)v.getContext( ).getSystemService(Context.INPUT_METHOD_SERVICE);
        return imm.isActive();
    }
}
